// 
//  Copyright (C) 2009 Jacek Trubłajewicz
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 

using System;

namespace wxGadu
{
	/// <summary>
	/// Represents type of chat or history message
	/// </summary>
	[Serializable]
	public enum ChatMessageType
	{
		IN,
		OUT
	}
	
	/// <summary>
	/// Represents single history message
	/// </summary>
	[Serializable]
	public class HistoryMsg
	{
		private int uin;
		private string name;
		private System.DateTime time;
		private string message;
		private ChatMessageType type;
		
		/// <summary>
		/// Ctor
		/// </summary>
		public HistoryMsg()
		{
		}
		
		/// <summary>
		/// Ctor
		/// </summary>
		/// <param name="uin">
		/// A <see cref="System.Int32"/>
		/// message sender UIN
		/// </param>
		/// <param name="name">
		/// A <see cref="System.String"/>
		/// message sender name
		/// </param>
		/// <param name="time">
		/// A <see cref="DateTime"/>
		/// send/revceive time
		/// </param>
		/// <param name="message">
		/// A <see cref="System.String"/>
		/// message body
		/// </param>
		/// <param name="type">
		/// A <see cref="ChatMessageType"/>
		/// type of message
		/// </param>
		public HistoryMsg(int uin, string name, DateTime time, string message, ChatMessageType type)
		{
			this.uin = uin;
			this.name = name;
			this.time = time;
			this.message = message;
			this.type = type;
		}
		
		//// <value>
		/// Sender UIN
		/// </value>
		public int U
		{
			get { return uin; }
			set { uin = value; }
		}
		
		//// <value>
		/// Sender name
		/// </value>
		public string N
		{
			get { return name == null ? string.Empty : name; }
			set { name = value == null ? string.Empty : value; }
		}
		
		//// <value>
		/// Send/receive date
		/// </value>
		public string D
		{
			get { return string.Format("{0:G}", time); }
			set { time = DateTime.Parse(value); }
		}
		
		//// <value>
		/// Message body
		/// </value>
		public string M
		{
			get { return message == null ? string.Empty : message; }
			set { message = value == null ? string.Empty : value; }
		}
		
		//// <value>
		/// Message type
		/// </value>
		public ChatMessageType T
		{
			get { return type; }
			set { type = value; }
		}
	}
}
